__notebook_source__.ipynb

  1. Kaggle Competition for House Prices: Advanced Regression Techniques
  2. Prediciton and selecting the Algorithm
  3. df_Test.drop(['SalePrice'],axis=1,inplace=True)
    1. Step2
    2. Artificial Neural Network Implementation
Skip to Main
Jupyter

__notebook_source__

Last Checkpoint: now
  • File
  • Edit
  • View
  • Run
  • Kernel
  • Settings
  • Help
## Kaggle Competition for House Prices: Advanced Regression Techniques

Kaggle Competition for House Prices: Advanced Regression Techniques¶

[2]:
# Import libraries

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
[3]:
df=pd.read_csv('/kaggle/input/house-price-predict/train.csv')
[4]:
df.head()
[4]:
Id MSSubClass MSZoning LotFrontage LotArea Street Alley LotShape LandContour Utilities ... PoolArea PoolQC Fence MiscFeature MiscVal MoSold YrSold SaleType SaleCondition SalePrice
0 1 60 RL 65.0 8450 Pave NaN Reg Lvl AllPub ... 0 NaN NaN NaN 0 2 2008 WD Normal 208500
1 2 20 RL 80.0 9600 Pave NaN Reg Lvl AllPub ... 0 NaN NaN NaN 0 5 2007 WD Normal 181500
2 3 60 RL 68.0 11250 Pave NaN IR1 Lvl AllPub ... 0 NaN NaN NaN 0 9 2008 WD Normal 223500
3 4 70 RL 60.0 9550 Pave NaN IR1 Lvl AllPub ... 0 NaN NaN NaN 0 2 2006 WD Abnorml 140000
4 5 60 RL 84.0 14260 Pave NaN IR1 Lvl AllPub ... 0 NaN NaN NaN 0 12 2008 WD Normal 250000

5 rows × 81 columns

[5]:
df['MSZoning'].value_counts()
[5]:
MSZoning
RL         1151
RM          218
FV           65
RH           16
C (all)      10
Name: count, dtype: int64
[6]:
df.isnull().sum()
[6]:
Id                 0
MSSubClass         0
MSZoning           0
LotFrontage      259
LotArea            0
                ... 
MoSold             0
YrSold             0
SaleType           0
SaleCondition      0
SalePrice          0
Length: 81, dtype: int64
[7]:
sns.heatmap(df.isnull(),yticklabels=False,cbar=False)
[7]:
<Axes: >
[8]:
df.shape
[8]:
(1460, 81)
[9]:
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 1460 entries, 0 to 1459
Data columns (total 81 columns):
 #   Column         Non-Null Count  Dtype  
---  ------         --------------  -----  
 0   Id             1460 non-null   int64  
 1   MSSubClass     1460 non-null   int64  
 2   MSZoning       1460 non-null   object 
 3   LotFrontage    1201 non-null   float64
 4   LotArea        1460 non-null   int64  
 5   Street         1460 non-null   object 
 6   Alley          91 non-null     object 
 7   LotShape       1460 non-null   object 
 8   LandContour    1460 non-null   object 
 9   Utilities      1460 non-null   object 
 10  LotConfig      1460 non-null   object 
 11  LandSlope      1460 non-null   object 
 12  Neighborhood   1460 non-null   object 
 13  Condition1     1460 non-null   object 
 14  Condition2     1460 non-null   object 
 15  BldgType       1460 non-null   object 
 16  HouseStyle     1460 non-null   object 
 17  OverallQual    1460 non-null   int64  
 18  OverallCond    1460 non-null   int64  
 19  YearBuilt      1460 non-null   int64  
 20  YearRemodAdd   1460 non-null   int64  
 21  RoofStyle      1460 non-null   object 
 22  RoofMatl       1460 non-null   object 
 23  Exterior1st    1460 non-null   object 
 24  Exterior2nd    1460 non-null   object 
 25  MasVnrType     588 non-null    object 
 26  MasVnrArea     1452 non-null   float64
 27  ExterQual      1460 non-null   object 
 28  ExterCond      1460 non-null   object 
 29  Foundation     1460 non-null   object 
 30  BsmtQual       1423 non-null   object 
 31  BsmtCond       1423 non-null   object 
 32  BsmtExposure   1422 non-null   object 
 33  BsmtFinType1   1423 non-null   object 
 34  BsmtFinSF1     1460 non-null   int64  
 35  BsmtFinType2   1422 non-null   object 
 36  BsmtFinSF2     1460 non-null   int64  
 37  BsmtUnfSF      1460 non-null   int64  
 38  TotalBsmtSF    1460 non-null   int64  
 39  Heating        1460 non-null   object 
 40  HeatingQC      1460 non-null   object 
 41  CentralAir     1460 non-null   object 
 42  Electrical     1459 non-null   object 
 43  1stFlrSF       1460 non-null   int64  
 44  2ndFlrSF       1460 non-null   int64  
 45  LowQualFinSF   1460 non-null   int64  
 46  GrLivArea      1460 non-null   int64  
 47  BsmtFullBath   1460 non-null   int64  
 48  BsmtHalfBath   1460 non-null   int64  
 49  FullBath       1460 non-null   int64  
 50  HalfBath       1460 non-null   int64  
 51  BedroomAbvGr   1460 non-null   int64  
 52  KitchenAbvGr   1460 non-null   int64  
 53  KitchenQual    1460 non-null   object 
 54  TotRmsAbvGrd   1460 non-null   int64  
 55  Functional     1460 non-null   object 
 56  Fireplaces     1460 non-null   int64  
 57  FireplaceQu    770 non-null    object 
 58  GarageType     1379 non-null   object 
 59  GarageYrBlt    1379 non-null   float64
 60  GarageFinish   1379 non-null   object 
 61  GarageCars     1460 non-null   int64  
 62  GarageArea     1460 non-null   int64  
 63  GarageQual     1379 non-null   object 
 64  GarageCond     1379 non-null   object 
 65  PavedDrive     1460 non-null   object 
 66  WoodDeckSF     1460 non-null   int64  
 67  OpenPorchSF    1460 non-null   int64  
 68  EnclosedPorch  1460 non-null   int64  
 69  3SsnPorch      1460 non-null   int64  
 70  ScreenPorch    1460 non-null   int64  
 71  PoolArea       1460 non-null   int64  
 72  PoolQC         7 non-null      object 
 73  Fence          281 non-null    object 
 74  MiscFeature    54 non-null     object 
 75  MiscVal        1460 non-null   int64  
 76  MoSold         1460 non-null   int64  
 77  YrSold         1460 non-null   int64  
 78  SaleType       1460 non-null   object 
 79  SaleCondition  1460 non-null   object 
 80  SalePrice      1460 non-null   int64  
dtypes: float64(3), int64(35), object(43)
memory usage: 924.0+ KB
[10]:
## Fill Missing Values

df['LotFrontage']=df['LotFrontage'].fillna(df['LotFrontage'].mean())
[11]:
df.drop(['Alley'],axis=1,inplace=True)
[12]:
df['BsmtCond']=df['BsmtCond'].fillna(df['BsmtCond'].mode()[0])
df['BsmtQual']=df['BsmtQual'].fillna(df['BsmtQual'].mode()[0])
[13]:
df['FireplaceQu']=df['FireplaceQu'].fillna(df['FireplaceQu'].mode()[0])
df['GarageType']=df['GarageType'].fillna(df['GarageType'].mode()[0])
[14]:
df.drop(['GarageYrBlt'],axis=1,inplace=True)
[15]:
df['GarageFinish']=df['GarageFinish'].fillna(df['GarageFinish'].mode()[0])
df['GarageQual']=df['GarageQual'].fillna(df['GarageQual'].mode()[0])
df['GarageCond']=df['GarageCond'].fillna(df['GarageCond'].mode()[0])
[16]:
df.drop(['PoolQC','Fence','MiscFeature'],axis=1,inplace=True)
[17]:
df.shape
[17]:
(1460, 76)
[18]:
df.drop(['Id'],axis=1,inplace=True)
[19]:
df.isnull().sum()
[19]:
MSSubClass       0
MSZoning         0
LotFrontage      0
LotArea          0
Street           0
                ..
MoSold           0
YrSold           0
SaleType         0
SaleCondition    0
SalePrice        0
Length: 75, dtype: int64
[20]:
df['MasVnrType']=df['MasVnrType'].fillna(df['MasVnrType'].mode()[0])
df['MasVnrArea']=df['MasVnrArea'].fillna(df['MasVnrArea'].mode()[0])
[21]:
sns.heatmap(df.isnull(),yticklabels=False,cbar=False,cmap='coolwarm')
[21]:
<Axes: >
[22]:
df['BsmtExposure']=df['BsmtExposure'].fillna(df['BsmtExposure'].mode()[0])
[23]:
sns.heatmap(df.isnull(),yticklabels=False,cbar=False,cmap='YlGnBu')
[23]:
<Axes: >
[24]:
df['BsmtFinType2']=df['BsmtFinType2'].fillna(df['BsmtFinType2'].mode()[0])
[25]:
df.dropna(inplace=True)
[26]:
df.shape
[26]:
(1422, 75)
[27]:
df.head()
[27]:
MSSubClass MSZoning LotFrontage LotArea Street LotShape LandContour Utilities LotConfig LandSlope ... EnclosedPorch 3SsnPorch ScreenPorch PoolArea MiscVal MoSold YrSold SaleType SaleCondition SalePrice
0 60 RL 65.0 8450 Pave Reg Lvl AllPub Inside Gtl ... 0 0 0 0 0 2 2008 WD Normal 208500
1 20 RL 80.0 9600 Pave Reg Lvl AllPub FR2 Gtl ... 0 0 0 0 0 5 2007 WD Normal 181500
2 60 RL 68.0 11250 Pave IR1 Lvl AllPub Inside Gtl ... 0 0 0 0 0 9 2008 WD Normal 223500
3 70 RL 60.0 9550 Pave IR1 Lvl AllPub Corner Gtl ... 272 0 0 0 0 2 2006 WD Abnorml 140000
4 60 RL 84.0 14260 Pave IR1 Lvl AllPub FR2 Gtl ... 0 0 0 0 0 12 2008 WD Normal 250000

5 rows × 75 columns

[28]:
##HAndle Categorical Features
[29]:
columns=['MSZoning','Street','LotShape','LandContour','Utilities','LotConfig','LandSlope','Neighborhood',
'Condition2','BldgType','Condition1','HouseStyle','SaleType',
'SaleCondition','ExterCond',
'ExterQual','Foundation','BsmtQual','BsmtCond','BsmtExposure','BsmtFinType1','BsmtFinType2',
'RoofStyle','RoofMatl','Exterior1st','Exterior2nd','MasVnrType','Heating','HeatingQC',
'CentralAir',
'Electrical','KitchenQual','Functional',
'FireplaceQu','GarageType','GarageFinish','GarageQual','GarageCond','PavedDrive']
[30]:
len(columns)
[30]:
39
[31]:
def category_onehot_multcols(multcolumns):
df_final=final_df
i=0
for fields in multcolumns:
print(fields)
df1=pd.get_dummies(final_df[fields],drop_first=True)
final_df.drop([fields],axis=1,inplace=True)
if i==0:
df_final=df1.copy()
else:
df_final=pd.concat([df_final,df1],axis=1)
i=i+1
df_final=pd.concat([final_df,df_final],axis=1)
return df_final
[32]:
main_df=df.copy()
[33]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
[34]:
test_df = pd.read_csv('/kaggle/input/house-price-predict/test.csv')

[35]:
test_df.shape
[35]:
(1459, 80)
[36]:
test_df.head()
[36]:
Id MSSubClass MSZoning LotFrontage LotArea Street Alley LotShape LandContour Utilities ... ScreenPorch PoolArea PoolQC Fence MiscFeature MiscVal MoSold YrSold SaleType SaleCondition
0 1461 20 RH 80.0 11622 Pave NaN Reg Lvl AllPub ... 120 0 NaN MnPrv NaN 0 6 2010 WD Normal
1 1462 20 RL 81.0 14267 Pave NaN IR1 Lvl AllPub ... 0 0 NaN NaN Gar2 12500 6 2010 WD Normal
2 1463 60 RL 74.0 13830 Pave NaN IR1 Lvl AllPub ... 0 0 NaN MnPrv NaN 0 3 2010 WD Normal
3 1464 60 RL 78.0 9978 Pave NaN IR1 Lvl AllPub ... 0 0 NaN NaN NaN 0 6 2010 WD Normal
4 1465 120 RL 43.0 5005 Pave NaN IR1 HLS AllPub ... 144 0 NaN NaN NaN 0 1 2010 WD Normal

5 rows × 80 columns

[37]:
#check null values
test_df.isnull().sum()
[37]:
Id                 0
MSSubClass         0
MSZoning           4
LotFrontage      227
LotArea            0
                ... 
MiscVal            0
MoSold             0
YrSold             0
SaleType           1
SaleCondition      0
Length: 80, dtype: int64
[38]:
Selection deleted
# Fill Missing Values

test_df['LotFrontage']=test_df['LotFrontage'].fillna(test_df['LotFrontage'].mean())
[39]:
Selection deleted
test_df['MSZoning']=test_df['MSZoning'].fillna(test_df['MSZoning'].mode()[0])
[40]:
test_df.shape


[40]:
(1459, 80)
[41]:
test_df.drop(['Alley'],axis=1,inplace=True)
[42]:
test_df.shape
[42]:
(1459, 79)
[43]:
test_df['BsmtCond']=test_df['BsmtCond'].fillna(test_df['BsmtCond'].mode()[0])
test_df['BsmtQual']=test_df['BsmtQual'].fillna(test_df['BsmtQual'].mode()[0])
[44]:
test_df['FireplaceQu']=test_df['FireplaceQu'].fillna(test_df['FireplaceQu'].mode()[0])
test_df['GarageType']=test_df['GarageType'].fillna(test_df['GarageType'].mode()[0])
[45]:
test_df.drop(['GarageYrBlt'],axis=1,inplace=True)
[46]:
test_df.shape
[46]:
(1459, 78)
[47]:
test_df['GarageFinish']=test_df['GarageFinish'].fillna(test_df['GarageFinish'].mode()[0])
test_df['GarageQual']=test_df['GarageQual'].fillna(test_df['GarageQual'].mode()[0])
test_df['GarageCond']=test_df['GarageCond'].fillna(test_df['GarageCond'].mode()[0])

test_df.drop(['PoolQC','Fence','MiscFeature'],axis=1,inplace=True)
[48]:
test_df.shape
[48]:
(1459, 75)
[49]:
test_df.drop(['Id'],axis=1,inplace=True)
[50]:
test_df['MasVnrType']=test_df['MasVnrType'].fillna(test_df['MasVnrType'].mode()[0])
test_df['MasVnrArea']=test_df['MasVnrArea'].fillna(test_df['MasVnrArea'].mode()[0])
[51]:
sns.heatmap(test_df.isnull(),yticklabels=False,cbar=False,cmap='viridis')
[51]:
<Axes: >
[52]:
test_df['BsmtExposure']=test_df['BsmtExposure'].fillna(test_df['BsmtExposure'].mode()[0])
[53]:
sns.heatmap(test_df.isnull(),yticklabels=False,cbar=False,cmap='viridis')
[53]:
<Axes: >
[54]:
test_df['BsmtFinType2']=test_df['BsmtFinType2'].fillna(test_df['BsmtFinType2'].mode()[0])
[55]:
test_df.loc[:, test_df.isnull().any()].head()
[55]:
Utilities Exterior1st Exterior2nd BsmtFinType1 BsmtFinSF1 BsmtFinSF2 BsmtUnfSF TotalBsmtSF BsmtFullBath BsmtHalfBath KitchenQual Functional GarageCars GarageArea SaleType
0 AllPub VinylSd VinylSd Rec 468.0 144.0 270.0 882.0 0.0 0.0 TA Typ 1.0 730.0 WD
1 AllPub Wd Sdng Wd Sdng ALQ 923.0 0.0 406.0 1329.0 0.0 0.0 Gd Typ 1.0 312.0 WD
2 AllPub VinylSd VinylSd GLQ 791.0 0.0 137.0 928.0 0.0 0.0 TA Typ 2.0 482.0 WD
3 AllPub VinylSd VinylSd GLQ 602.0 0.0 324.0 926.0 0.0 0.0 Gd Typ 2.0 470.0 WD
4 AllPub HdBoard HdBoard ALQ 263.0 0.0 1017.0 1280.0 0.0 0.0 Gd Typ 2.0 506.0 WD
[56]:
test_df['Utilities']=test_df['Utilities'].fillna(test_df['Utilities'].mode()[0])
test_df['Exterior1st']=test_df['Exterior1st'].fillna(test_df['Exterior1st'].mode()[0])
test_df['Exterior2nd']=test_df['Exterior2nd'].fillna(test_df['Exterior2nd'].mode()[0])
test_df['BsmtFinType1']=test_df['BsmtFinType1'].fillna(test_df['BsmtFinType1'].mode()[0])
test_df['BsmtFinSF1']=test_df['BsmtFinSF1'].fillna(test_df['BsmtFinSF1'].mean())
test_df['BsmtFinSF2']=test_df['BsmtFinSF2'].fillna(test_df['BsmtFinSF2'].mean())
test_df['BsmtUnfSF']=test_df['BsmtUnfSF'].fillna(test_df['BsmtUnfSF'].mean())
test_df['TotalBsmtSF']=test_df['TotalBsmtSF'].fillna(test_df['TotalBsmtSF'].mean())
test_df['BsmtFullBath']=test_df['BsmtFullBath'].fillna(test_df['BsmtFullBath'].mode()[0])
test_df['BsmtHalfBath']=test_df['BsmtHalfBath'].fillna(test_df['BsmtHalfBath'].mode()[0])
test_df['KitchenQual']=test_df['KitchenQual'].fillna(test_df['KitchenQual'].mode()[0])
test_df['Functional']=test_df['Functional'].fillna(test_df['Functional'].mode()[0])
test_df['GarageCars']=test_df['GarageCars'].fillna(test_df['GarageCars'].mean())
test_df['GarageArea']=test_df['GarageArea'].fillna(test_df['GarageArea'].mean())
test_df['SaleType']=test_df['SaleType'].fillna(test_df['SaleType'].mode()[0])

[57]:
test_df.shape
[57]:
(1459, 74)
[97]:
test_df.to_csv('formulatedtest.csv',index=False)
[98]:
## Combine Test Data

test_df=pd.read_csv('formulatedtest.csv')
[99]:
test_df.shape
[99]:
(1459, 74)
[100]:
test_df.head()
[100]:
MSSubClass MSZoning LotFrontage LotArea Street LotShape LandContour Utilities LotConfig LandSlope ... OpenPorchSF EnclosedPorch 3SsnPorch ScreenPorch PoolArea MiscVal MoSold YrSold SaleType SaleCondition
0 20 RH 80.0 11622 Pave Reg Lvl AllPub Inside Gtl ... 0 0 0 120 0 0 6 2010 WD Normal
1 20 RL 81.0 14267 Pave IR1 Lvl AllPub Corner Gtl ... 36 0 0 0 0 12500 6 2010 WD Normal
2 60 RL 74.0 13830 Pave IR1 Lvl AllPub Inside Gtl ... 34 0 0 0 0 0 3 2010 WD Normal
3 60 RL 78.0 9978 Pave IR1 Lvl AllPub Inside Gtl ... 36 0 0 0 0 0 6 2010 WD Normal
4 120 RL 43.0 5005 Pave IR1 HLS AllPub Inside Gtl ... 82 0 0 144 0 0 1 2010 WD Normal

5 rows × 74 columns

[101]:
final_df=pd.concat([df,test_df],axis=0)
[102]:
final_df.shape
[102]:
(2881, 75)
[63]:
final_df['SalePrice']
[63]:
0       208500.0
1       181500.0
2       223500.0
3       140000.0
4       250000.0
          ...   
1454         NaN
1455         NaN
1456         NaN
1457         NaN
1458         NaN
Name: SalePrice, Length: 2881, dtype: float64
[64]:
final_df.shape
[64]:
(2881, 75)
[103]:
final_df=category_onehot_multcols(columns)
MSZoning
Street
LotShape
LandContour
Utilities
LotConfig
LandSlope
Neighborhood
Condition2
BldgType
Condition1
HouseStyle
SaleType
SaleCondition
ExterCond
ExterQual
Foundation
BsmtQual
BsmtCond
BsmtExposure
BsmtFinType1
BsmtFinType2
RoofStyle
RoofMatl
Exterior1st
Exterior2nd
MasVnrType
Heating
HeatingQC
CentralAir
Electrical
KitchenQual
Functional
FireplaceQu
GarageType
GarageFinish
GarageQual
GarageCond
PavedDrive
[104]:
final_df.shape
[104]:
(2881, 234)
[105]:
final_df =final_df.loc[:,~final_df.columns.duplicated()]
[106]:
final_df.shape
[106]:
(2881, 174)
[69]:
final_df
[69]:
MSSubClass LotFrontage LotArea OverallQual OverallCond YearBuilt YearRemodAdd MasVnrArea BsmtFinSF1 BsmtFinSF2 ... Min1 Min2 Typ Attchd Basment BuiltIn CarPort Detchd RFn P
0 60 65.0 8450 7 5 2003 2003 196.0 706.0 0.0 ... False False True True False False False False True False
1 20 80.0 9600 6 8 1976 1976 0.0 978.0 0.0 ... False False True True False False False False True False
2 60 68.0 11250 7 5 2001 2002 162.0 486.0 0.0 ... False False True True False False False False True False
3 70 60.0 9550 7 5 1915 1970 0.0 216.0 0.0 ... False False True False False False False True False False
4 60 84.0 14260 8 5 2000 2000 350.0 655.0 0.0 ... False False True True False False False False True False
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
1454 160 21.0 1936 4 7 1970 1970 0.0 0.0 0.0 ... False False True True False False False False False False
1455 160 21.0 1894 4 5 1970 1970 0.0 252.0 0.0 ... False False True False False False True False False False
1456 20 160.0 20000 5 7 1960 1996 0.0 1224.0 0.0 ... False False True False False False False True False False
1457 85 62.0 10441 5 5 1992 1992 0.0 337.0 0.0 ... False False True True False False False False False False
1458 60 74.0 9627 7 5 1993 1994 94.0 758.0 0.0 ... False False True True False False False False False False

2881 rows × 174 columns

[107]:
df_Train=final_df.iloc[:1422,:]
df_Test=final_df.iloc[1422:,:]
[71]:
df_Train.head()
[71]:
MSSubClass LotFrontage LotArea OverallQual OverallCond YearBuilt YearRemodAdd MasVnrArea BsmtFinSF1 BsmtFinSF2 ... Min1 Min2 Typ Attchd Basment BuiltIn CarPort Detchd RFn P
0 60 65.0 8450 7 5 2003 2003 196.0 706.0 0.0 ... False False True True False False False False True False
1 20 80.0 9600 6 8 1976 1976 0.0 978.0 0.0 ... False False True True False False False False True False
2 60 68.0 11250 7 5 2001 2002 162.0 486.0 0.0 ... False False True True False False False False True False
3 70 60.0 9550 7 5 1915 1970 0.0 216.0 0.0 ... False False True False False False False True False False
4 60 84.0 14260 8 5 2000 2000 350.0 655.0 0.0 ... False False True True False False False False True False

5 rows × 174 columns

[72]:
df_Test.head()
[72]:
MSSubClass LotFrontage LotArea OverallQual OverallCond YearBuilt YearRemodAdd MasVnrArea BsmtFinSF1 BsmtFinSF2 ... Min1 Min2 Typ Attchd Basment BuiltIn CarPort Detchd RFn P
0 20 80.0 11622 5 6 1961 1961 0.0 468.0 144.0 ... False False True True False False False False False False
1 20 81.0 14267 6 6 1958 1958 108.0 923.0 0.0 ... False False True True False False False False False False
2 60 74.0 13830 5 5 1997 1998 0.0 791.0 0.0 ... False False True True False False False False False False
3 60 78.0 9978 6 6 1998 1998 20.0 602.0 0.0 ... False False True True False False False False False False
4 120 43.0 5005 8 5 1992 1992 0.0 263.0 0.0 ... False False True True False False False False True False

5 rows × 174 columns

[73]:
df_Train.shape
[73]:
(1422, 174)
[108]:
df_Test.drop(['SalePrice'],axis=1,inplace=True)
/tmp/ipykernel_24/3985304647.py:1: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  df_Test.drop(['SalePrice'],axis=1,inplace=True)
[109]:
df_Test.shape
[109]:
(1459, 173)
[110]:
X_train=df_Train.drop(['SalePrice'],axis=1)
y_train=df_Train['SalePrice']

## Prediciton and selecting the Algorithm

Prediciton and selecting the Algorithm¶

[111]:
import xgboost
classifier=xgboost.XGBRegressor()
classifier.fit(X_train,y_train)
[111]:
XGBRegressor(base_score=None, booster=None, callbacks=None,
             colsample_bylevel=None, colsample_bynode=None,
             colsample_bytree=None, device=None, early_stopping_rounds=None,
             enable_categorical=False, eval_metric=None, feature_types=None,
             gamma=None, grow_policy=None, importance_type=None,
             interaction_constraints=None, learning_rate=None, max_bin=None,
             max_cat_threshold=None, max_cat_to_onehot=None,
             max_delta_step=None, max_depth=None, max_leaves=None,
             min_child_weight=None, missing=nan, monotone_constraints=None,
             multi_strategy=None, n_estimators=None, n_jobs=None,
             num_parallel_tree=None, random_state=None, ...)
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
XGBRegressor(base_score=None, booster=None, callbacks=None,
             colsample_bylevel=None, colsample_bynode=None,
             colsample_bytree=None, device=None, early_stopping_rounds=None,
             enable_categorical=False, eval_metric=None, feature_types=None,
             gamma=None, grow_policy=None, importance_type=None,
             interaction_constraints=None, learning_rate=None, max_bin=None,
             max_cat_threshold=None, max_cat_to_onehot=None,
             max_delta_step=None, max_depth=None, max_leaves=None,
             min_child_weight=None, missing=nan, monotone_constraints=None,
             multi_strategy=None, n_estimators=None, n_jobs=None,
             num_parallel_tree=None, random_state=None, ...)
[77]:
import xgboost
regressor=xgboost.XGBRegressor()
[78]:
booster=['gbtree','gblinear']
base_score=[0.25,0.5,0.75,1]
[79]:
## Hyper Parameter Optimization


n_estimators = [100, 500, 900, 1100, 1500]
max_depth = [2, 3, 5, 10, 15]
booster=['gbtree','gblinear']
learning_rate=[0.05,0.1,0.15,0.20]
min_child_weight=[1,2,3,4]

# Define the grid of hyperparameters to search
hyperparameter_grid = {
'n_estimators': n_estimators,
'max_depth':max_depth,
'learning_rate':learning_rate,
'min_child_weight':min_child_weight,
'booster':booster,
'base_score':base_score
}
[89]:
from sklearn.model_selection import RandomizedSearchCV
[90]:
# Set up the random search with 4-fold cross validation
random_cv = RandomizedSearchCV(estimator=regressor,
param_distributions=hyperparameter_grid,
cv=5, n_iter=50,
scoring = 'neg_mean_absolute_error',n_jobs = 4,
verbose = 5,
return_train_score = True,
random_state=42)
[ ]:
random_cv.best_estimator_
[ ]:
random_cv.best_estimator_
[ ]:
regressor=xgboost.XGBRegressor(base_score=0.25, booster='gbtree', colsample_bylevel=1,
colsample_bytree=1, gamma=0, learning_rate=0.1, max_delta_step=0,
max_depth=2, min_child_weight=1, missing=None, n_estimators=900,
n_jobs=1, nthread=None, objective='reg:linear', random_state=0,
reg_alpha=0, reg_lambda=1, scale_pos_weight=1, seed=None,
silent=True, subsample=1)
[82]:
regressor.fit(X_train,y_train)
/opt/conda/lib/python3.10/site-packages/xgboost/core.py:160: UserWarning: [05:32:05] WARNING: /workspace/src/objective/regression_obj.cu:209: reg:linear is now deprecated in favor of reg:squarederror.
  warnings.warn(smsg, UserWarning)
/opt/conda/lib/python3.10/site-packages/xgboost/core.py:160: UserWarning: [05:32:05] WARNING: /workspace/src/learner.cc:742: 
Parameters: { "silent" } are not used.

  warnings.warn(smsg, UserWarning)
[82]:
XGBRegressor(base_score=0.25, booster='gbtree', callbacks=None,
             colsample_bylevel=1, colsample_bynode=None, colsample_bytree=1,
             device=None, early_stopping_rounds=None, enable_categorical=False,
             eval_metric=None, feature_types=None, gamma=0, grow_policy=None,
             importance_type=None, interaction_constraints=None,
             learning_rate=0.1, max_bin=None, max_cat_threshold=None,
             max_cat_to_onehot=None, max_delta_step=0, max_depth=2,
             max_leaves=None, min_child_weight=1, missing=None,
             monotone_constraints=None, multi_strategy=None, n_estimators=900,
             n_jobs=1, nthread=None, num_parallel_tree=None, ...)
In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.
XGBRegressor(base_score=0.25, booster='gbtree', callbacks=None,
             colsample_bylevel=1, colsample_bynode=None, colsample_bytree=1,
             device=None, early_stopping_rounds=None, enable_categorical=False,
             eval_metric=None, feature_types=None, gamma=0, grow_policy=None,
             importance_type=None, interaction_constraints=None,
             learning_rate=0.1, max_bin=None, max_cat_threshold=None,
             max_cat_to_onehot=None, max_delta_step=0, max_depth=2,
             max_leaves=None, min_child_weight=1, missing=None,
             monotone_constraints=None, multi_strategy=None, n_estimators=900,
             n_jobs=1, nthread=None, num_parallel_tree=None, ...)
[112]:
import pickle
filename = 'finalized_model.pkl'
pickle.dump(classifier, open(filename, 'wb'))
[113]:
y_pred=classifier.predict(df_Test)
[114]:
y_pred
[114]:
array([132912.3 , 147271.73, 195217.86, ..., 167273.81, 103442.8 ,
       241069.48], dtype=float32)
[117]:
import os
print(os.getcwd())

/kaggle/working
[121]:
import os

# Define the directory path where you want to save the file
directory = '/kaggle/working/sample_submission_dir'

# Create the directory if it does not exist
if not os.path.exists(directory):
os.makedirs(directory)

[122]:
# Define the full path for the sample submission file
file_path = os.path.join(directory, 'sample_submission.csv')

[125]:
import pandas as pd

# Example: Assuming y_pred contains predictions and sub_df contains IDs
pred = pd.DataFrame(y_pred, columns=['SalePrice']) # Ensure y_pred is defined
sub_df = pd.DataFrame({'Id': range(1, len(y_pred) + 1)}) # Replace with actual IDs

# Combine the two DataFrames
datasets = pd.concat([sub_df['Id'], pred], axis=1)
datasets.columns = ['Id', 'SalePrice']

[126]:
print(datasets.head())

   Id      SalePrice
0   1  132912.296875
1   2  147271.734375
2   3  195217.859375
3   4  193647.890625
4   5  194645.281250
[127]:
# Save the DataFrame to the specified directory
datasets.to_csv(file_path, index=False)

print(f"File saved to {file_path}")
File saved to /kaggle/working/sample_submission_dir/sample_submission.csv
[133]:
import os
print(os.listdir('/kaggle/working'))

['finalized_model.pkl', 'sample_submission_dir', 'formulatedtest.csv', '.virtual_documents']
[ ]:

[135]:
Selection deleted
##Create Sample Submission file and Submit
pred=pd.DataFrame(y_pred)
sub_df=pd.read_csv('sample_submission.csv')
datasets=pd.concat([sub_df['Id'],pred],axis=1)
datasets.columns=['Id','SalePrice']
datasets.to_csv('/kaggle/working/sample_submission_dir/sample_submission.csv', index=False)


---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[135], line 3
      1 ##Create Sample Submission file and Submit 
      2 pred=pd.DataFrame(y_pred)
----> 3 sub_df=pd.read_csv('sample_submission.csv')
      4 datasets=pd.concat([sub_df['Id'],pred],axis=1)
      5 datasets.columns=['Id','SalePrice']

File /opt/conda/lib/python3.10/site-packages/pandas/io/parsers/readers.py:1026, in read_csv(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, date_format, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, encoding_errors, dialect, on_bad_lines, delim_whitespace, low_memory, memory_map, float_precision, storage_options, dtype_backend)
   1013 kwds_defaults = _refine_defaults_read(
   1014     dialect,
   1015     delimiter,
   (...)
   1022     dtype_backend=dtype_backend,
   1023 )
   1024 kwds.update(kwds_defaults)
-> 1026 return _read(filepath_or_buffer, kwds)

File /opt/conda/lib/python3.10/site-packages/pandas/io/parsers/readers.py:620, in _read(filepath_or_buffer, kwds)
    617 _validate_names(kwds.get("names", None))
    619 # Create the parser.
--> 620 parser = TextFileReader(filepath_or_buffer, **kwds)
    622 if chunksize or iterator:
    623     return parser

File /opt/conda/lib/python3.10/site-packages/pandas/io/parsers/readers.py:1620, in TextFileReader.__init__(self, f, engine, **kwds)
   1617     self.options["has_index_names"] = kwds["has_index_names"]
   1619 self.handles: IOHandles | None = None
-> 1620 self._engine = self._make_engine(f, self.engine)

File /opt/conda/lib/python3.10/site-packages/pandas/io/parsers/readers.py:1880, in TextFileReader._make_engine(self, f, engine)
   1878     if "b" not in mode:
   1879         mode += "b"
-> 1880 self.handles = get_handle(
   1881     f,
   1882     mode,
   1883     encoding=self.options.get("encoding", None),
   1884     compression=self.options.get("compression", None),
   1885     memory_map=self.options.get("memory_map", False),
   1886     is_text=is_text,
   1887     errors=self.options.get("encoding_errors", "strict"),
   1888     storage_options=self.options.get("storage_options", None),
   1889 )
   1890 assert self.handles is not None
   1891 f = self.handles.handle

File /opt/conda/lib/python3.10/site-packages/pandas/io/common.py:873, in get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)
    868 elif isinstance(handle, str):
    869     # Check whether the filename is to be opened in binary mode.
    870     # Binary mode does not support 'encoding' and 'newline'.
    871     if ioargs.encoding and "b" not in ioargs.mode:
    872         # Encoding
--> 873         handle = open(
    874             handle,
    875             ioargs.mode,
    876             encoding=ioargs.encoding,
    877             errors=errors,
    878             newline="",
    879         )
    880     else:
    881         # Binary mode
    882         handle = open(handle, ioargs.mode)

FileNotFoundError: [Errno 2] No such file or directory: 'sample_submission.csv'
# df_Test.drop(['SalePrice'],axis=1,inplace=True)

df_Test.drop(['SalePrice'],axis=1,inplace=True)¶

[92]:
df_Test.shape
[92]:
(1459, 173)
[93]:
df_Test.head()
[93]:
MSSubClass LotFrontage LotArea OverallQual OverallCond YearBuilt YearRemodAdd MasVnrArea BsmtFinSF1 BsmtFinSF2 ... Min1 Min2 Typ Attchd Basment BuiltIn CarPort Detchd RFn P
0 20 80.0 11622 5 6 1961 1961 0.0 468.0 144.0 ... False False True True False False False False False False
1 20 81.0 14267 6 6 1958 1958 108.0 923.0 0.0 ... False False True True False False False False False False
2 60 74.0 13830 5 5 1997 1998 0.0 791.0 0.0 ... False False True True False False False False False False
3 60 78.0 9978 6 6 1998 1998 20.0 602.0 0.0 ... False False True True False False False False False False
4 120 43.0 5005 8 5 1992 1992 0.0 263.0 0.0 ... False False True True False False False False True False

5 rows × 173 columns

[87]:
df_Test.drop(['SalePrice'],axis=1).head()
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[87], line 1
----> 1 df_Test.drop(['SalePrice'],axis=1).head()

File /opt/conda/lib/python3.10/site-packages/pandas/core/frame.py:5581, in DataFrame.drop(self, labels, axis, index, columns, level, inplace, errors)
   5433 def drop(
   5434     self,
   5435     labels: IndexLabel | None = None,
   (...)
   5442     errors: IgnoreRaise = "raise",
   5443 ) -> DataFrame | None:
   5444     """
   5445     Drop specified labels from rows or columns.
   5446 
   (...)
   5579             weight  1.0     0.8
   5580     """
-> 5581     return super().drop(
   5582         labels=labels,
   5583         axis=axis,
   5584         index=index,
   5585         columns=columns,
   5586         level=level,
   5587         inplace=inplace,
   5588         errors=errors,
   5589     )

File /opt/conda/lib/python3.10/site-packages/pandas/core/generic.py:4788, in NDFrame.drop(self, labels, axis, index, columns, level, inplace, errors)
   4786 for axis, labels in axes.items():
   4787     if labels is not None:
-> 4788         obj = obj._drop_axis(labels, axis, level=level, errors=errors)
   4790 if inplace:
   4791     self._update_inplace(obj)

File /opt/conda/lib/python3.10/site-packages/pandas/core/generic.py:4830, in NDFrame._drop_axis(self, labels, axis, level, errors, only_slice)
   4828         new_axis = axis.drop(labels, level=level, errors=errors)
   4829     else:
-> 4830         new_axis = axis.drop(labels, errors=errors)
   4831     indexer = axis.get_indexer(new_axis)
   4833 # Case for non-unique axis
   4834 else:

File /opt/conda/lib/python3.10/site-packages/pandas/core/indexes/base.py:7070, in Index.drop(self, labels, errors)
   7068 if mask.any():
   7069     if errors != "ignore":
-> 7070         raise KeyError(f"{labels[mask].tolist()} not found in axis")
   7071     indexer = indexer[~mask]
   7072 return self.delete(indexer)

KeyError: "['SalePrice'] not found in axis"
[94]:
y_pred=regressor.predict(df_Test.drop(['SalePrice'],axis=1))
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[94], line 1
----> 1 y_pred=regressor.predict(df_Test.drop(['SalePrice'],axis=1))

File /opt/conda/lib/python3.10/site-packages/pandas/core/frame.py:5581, in DataFrame.drop(self, labels, axis, index, columns, level, inplace, errors)
   5433 def drop(
   5434     self,
   5435     labels: IndexLabel | None = None,
   (...)
   5442     errors: IgnoreRaise = "raise",
   5443 ) -> DataFrame | None:
   5444     """
   5445     Drop specified labels from rows or columns.
   5446 
   (...)
   5579             weight  1.0     0.8
   5580     """
-> 5581     return super().drop(
   5582         labels=labels,
   5583         axis=axis,
   5584         index=index,
   5585         columns=columns,
   5586         level=level,
   5587         inplace=inplace,
   5588         errors=errors,
   5589     )

File /opt/conda/lib/python3.10/site-packages/pandas/core/generic.py:4788, in NDFrame.drop(self, labels, axis, index, columns, level, inplace, errors)
   4786 for axis, labels in axes.items():
   4787     if labels is not None:
-> 4788         obj = obj._drop_axis(labels, axis, level=level, errors=errors)
   4790 if inplace:
   4791     self._update_inplace(obj)

File /opt/conda/lib/python3.10/site-packages/pandas/core/generic.py:4830, in NDFrame._drop_axis(self, labels, axis, level, errors, only_slice)
   4828         new_axis = axis.drop(labels, level=level, errors=errors)
   4829     else:
-> 4830         new_axis = axis.drop(labels, errors=errors)
   4831     indexer = axis.get_indexer(new_axis)
   4833 # Case for non-unique axis
   4834 else:

File /opt/conda/lib/python3.10/site-packages/pandas/core/indexes/base.py:7070, in Index.drop(self, labels, errors)
   7068 if mask.any():
   7069     if errors != "ignore":
-> 7070         raise KeyError(f"{labels[mask].tolist()} not found in axis")
   7071     indexer = indexer[~mask]
   7072 return self.delete(indexer)

KeyError: "['SalePrice'] not found in axis"
[95]:
y_pred
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[95], line 1
----> 1 y_pred

NameError: name 'y_pred' is not defined
[ ]:

[96]:
##Create Sample Submission file and Submit using ANN
pred=pd.DataFrame(ann_pred)
sub_df=pd.read_csv('sample_submission.csv')
datasets=pd.concat([sub_df['Id'],pred],axis=1)
datasets.columns=['Id','SalePrice']
datasets.to_csv('sample_submission.csv',index=False)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[96], line 2
      1 ##Create Sample Submission file and Submit using ANN
----> 2 pred=pd.DataFrame(ann_pred)
      3 sub_df=pd.read_csv('sample_submission.csv')
      4 datasets=pd.concat([sub_df['Id'],pred],axis=1)

NameError: name 'ann_pred' is not defined
## Step2

Step2¶

[ ]:
pred.columns=['SalePrice']
[ ]:
temp_df=df_Train['SalePrice'].copy()
[ ]:
temp_df.column=['SalePrice']
[ ]:
df_Train.drop(['SalePrice'],axis=1,inplace=True)
[ ]:
df_Train=pd.concat([df_Train,temp_df],axis=1)
[ ]:
df_Test.head()
[ ]:
df_Test=pd.concat([df_Test,pred],axis=1)
[ ]:

[ ]:
df_Train=pd.concat([df_Train,df_Test],axis=0)
[ ]:
df_Train.shape
[ ]:
X_train=df_Train.drop(['SalePrice'],axis=1)
y_train=df_Train['SalePrice']
## Artificial Neural Network Implementation

Artificial Neural Network Implementation¶

[ ]:
# Importing the Keras libraries and packages
import keras
from keras.models import Sequential
from keras.layers import Dense
from keras.layers import LeakyReLU,PReLU,ELU
from keras.layers import Dropout


# Initialising the ANN
classifier = Sequential()

# Adding the input layer and the first hidden layer
classifier.add(Dense(output_dim = 50, init = 'he_uniform',activation='relu',input_dim = 174))

# Adding the second hidden layer
classifier.add(Dense(output_dim = 25, init = 'he_uniform',activation='relu'))

# Adding the third hidden layer
classifier.add(Dense(output_dim = 50, init = 'he_uniform',activation='relu'))
# Adding the output layer
classifier.add(Dense(output_dim = 1, init = 'he_uniform'))

# Compiling the ANN
classifier.compile(loss=root_mean_squared_error, optimizer='Adamax')

# Fitting the ANN to the Training set
model_history=classifier.fit(X_train.values, y_train.values,validation_split=0.20, batch_size = 10, nb_epoch = 1000)
[ ]:
ann_pred=classifier.predict(df_Test.drop(['SalePrice'],axis=1).values)
[ ]:
from keras import backend as K
def root_mean_squared_error(y_true, y_pred):
return K.sqrt(K.mean(K.square(y_pred - y_true)))
[ ]:

Notebook cell shifted down successfully
Common Tools
No metadata.
Advanced Tools
No metadata.
  • Open in...
Kernel status: Idle
  • y_predvariable
  • y_trainvariable

  • Console
  • Change Kernel…
  • Clear Console Cells
  • Close and Shut Down…
  • Insert Line Break
  • Interrupt Kernel
  • New Console
  • Restart Kernel…
  • Run Cell (forced)
  • Run Cell (unforced)
  • Show All Kernel Activity
  • Display Languages
  • English
    English
  • File Operations
  • Autosave Documents
  • Download
    Download the file to your computer
  • Reload Notebook from Disk
    Reload contents from disk
  • Revert Notebook to Checkpoint…
    Revert contents to previous checkpoint
  • Save Notebook
    Save and create checkpoint
  • Save Notebook As…
    Save with new path
  • Trust HTML File
    Whether the HTML file is trusted. Trusting the file allows scripts to run in it, which may result in security risks. Only enable for files you trust.
  • Help
  • About Jupyter Notebook
  • Launch Jupyter Notebook File Browser
  • Show Keyboard Shortcuts
    Show relevant keyboard shortcuts for the current active widget
    Ctrl+Shift+H
  • Image Viewer
  • Flip image horizontally
    H
  • Flip image vertically
    V
  • Invert Colors
    I
  • Reset Image
    0
  • Rotate Clockwise
    ]
  • Rotate Counterclockwise
    [
  • Zoom In
    =
  • Zoom Out
    -
  • Kernel Operations
  • Shut Down All Kernels…
  • Language server protocol
  • Display the completer themes
  • Language Server Protocol
  • Rename symbol
  • Show diagnostics panel
  • Main Area
  • Close All Other Tabs
  • Close Tab
    Alt+W
  • Close Tabs to Right
  • End Search
    Esc
  • Find Next
    Ctrl+G
  • Find Previous
    Ctrl+Shift+G
  • Find…
    Ctrl+F
  • Log Out
    Log out of JupyterLab
  • Shut Down
    Shut down JupyterLab
  • Mode
  • Toggle Zen Mode
  • Notebook Cell Operations
  • Change to Code Cell Type
    Y
  • Change to Heading 1
    1
  • Change to Heading 2
    2
  • Change to Heading 3
    3
  • Change to Heading 4
    4
  • Change to Heading 5
    5
  • Change to Heading 6
    6
  • Change to Markdown Cell Type
    M
  • Change to Raw Cell Type
    R
  • Clear Cell Output
    Clear outputs for the selected cells
  • Collapse All Code
  • Collapse All Outputs
  • Collapse Selected Code
  • Collapse Selected Outputs
  • Copy Cell
    Copy this cell
    C
  • Cut Cell
    Cut this cell
    X
  • Delete Cell
    Delete this cell
    D, D
  • Disable Scrolling for Outputs
  • Enable Scrolling for Outputs
  • Expand All Code
  • Expand All Outputs
  • Expand Selected Code
  • Expand Selected Outputs
  • Extend Selection Above
    Shift+K
  • Extend Selection Below
    Shift+J
  • Extend Selection to Bottom
    Shift+End
  • Extend Selection to Top
    Shift+Home
  • Insert Cell Above
    Insert a cell above
    A
  • Insert Cell Below
    Insert a cell below
    B
  • Insert Heading Above Current Heading
    Shift+A
  • Insert Heading Below Current Heading
    Shift+B
  • Merge Cell Above
    Ctrl+Backspace
  • Merge Cell Below
    Ctrl+Shift+M
  • Merge Selected Cells
    Shift+M
  • Move Cell Down
    Move this cell down
    Ctrl+Shift+Down
  • Move Cell Up
    Move this cell up
    Ctrl+Shift+Up
  • Paste Cell Above
    Paste this cell from the clipboard
  • Paste Cell and Replace
  • Paste Cell Below
    Paste this cell from the clipboard
    V
  • Redo Cell Operation
    Shift+Z
  • Render Side-by-Side
    Shift+R
  • Run Selected Cell
    Run this cell and advance
  • Run Selected Cell and Do not Advance
  • Run Selected Cell and Insert Below
  • Run Selected Text or Current Line in Console
  • Select Cell Above
    K
  • Select Cell Below
    J
  • Select Heading Above or Collapse Heading
    Left
  • Select Heading Below or Expand Heading
    Right
  • Set side-by-side ratio
  • Split Cell
    Ctrl+Shift+-
  • Undo Cell Operation
    Z
  • Notebook Operations
  • Change Kernel…
  • Clear Outputs of All Cells
    Clear all outputs of all cells
  • Close and Shut Down Notebook
  • Collapse All Headings
    Ctrl+Shift+Left
  • Deselect All Cells
  • Enter Command Mode
    Ctrl+M
  • Enter Edit Mode
    Enter
  • Expand All Headings
    Ctrl+Shift+Right
  • Interrupt Kernel
    Interrupt the kernel
  • New Console for Notebook
  • New Notebook
    Create a new notebook
  • Reconnect to Kernel
  • Render All Markdown Cells
  • Restart Kernel and Clear Outputs of All Cells…
    Restart the kernel and clear all outputs of all cells
  • Restart Kernel and Debug…
    Restart Kernel and Debug…
  • Restart Kernel and Run All Cells…
    Restart the kernel and run all cells
  • Restart Kernel and Run up to Selected Cell…
  • Restart Kernel…
    Restart the kernel
  • Run All Above Selected Cell
  • Run All Cells
    Run all cells
  • Run Selected Cell and All Below
  • Select All Cells
    Ctrl+A
  • Show Line Numbers
    Shift+L
  • Toggle Collapse Notebook Heading
  • Trust Notebook
  • Other
  • Open in JupyterLab
    JupyterLab
  • Open in NbClassic
    NbClassic
  • Terminal
  • Decrease Terminal Font Size
  • Increase Terminal Font Size
  • New Terminal
    Start a new terminal session
  • Refresh Terminal
    Refresh the current terminal session
  • Use Terminal Theme: Dark
    Set the terminal theme
  • Use Terminal Theme: Inherit
    Set the terminal theme
  • Use Terminal Theme: Light
    Set the terminal theme
  • Text Editor
  • Decrease Font Size
  • Increase Font Size
  • New Markdown File
    Create a new markdown file
  • New Python File
    Create a new Python file
  • New R File
    Create a new R file
  • New Text File
    Create a new text file
  • Spaces: 1
  • Spaces: 2
  • Spaces: 4
  • Spaces: 4
  • Spaces: 8
  • Theme
  • Decrease Code Font Size
  • Decrease Content Font Size
  • Decrease UI Font Size
  • Increase Code Font Size
  • Increase Content Font Size
  • Increase UI Font Size
  • Theme Scrollbars
  • Use Theme: JupyterLab Dark
  • Use Theme: JupyterLab Light
  • View
  • File Browser
  • Open JupyterLab
  • Show Header
  • Show Notebook Tools
    Show Show Notebook Tools in the right sidebar
  • Show Table of Contents
    Show Show Table of Contents in the left sidebar